package com.topc.participant.api;

import com.topc.base.api.CommonResult;
import com.topc.base.model.PageParams;
import com.topc.base.model.PageResult;
import com.topc.participant.model.dto.QueryGroupDto;
import com.topc.participant.model.po.GroupInfo;
import com.topc.participant.model.vo.GroupShowVo;
import com.topc.participant.service.ICourseUserMidService;
import com.topc.participant.service.IGroupInfoService;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/close/group")
public class GroupCloseController {

    @Autowired
    private IGroupInfoService groupInfoService;

    @Autowired
    private ICourseUserMidService courseUserMidService;

    @PostMapping(value="/search-info")
    public CommonResult<PageResult<GroupShowVo>> searchInfoByPage(PageParams pageParams,@RequestBody @Validated QueryGroupDto queryGroupDto){
        PageResult<GroupShowVo> groupShowVoPageResult =groupInfoService.searchInfoByPage(pageParams,queryGroupDto);
        return  CommonResult.success(groupShowVoPageResult);
    }

    @PostMapping("/update")
    public CommonResult<String> updateInfoById(@NotNull Long id,@Range(min=-1,max=2) int status){
        groupInfoService.updateInfoById(id,status);
        return  CommonResult.success("修改成功");
    }

}
